package com;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HttpCommandService extends HttpServlet {
	
	private DCMPToolUtil dcmpToolUtil = new DCMPToolUtil();
	
	public HttpCommandService() {
		super();
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		
		
		PrintWriter out = resp.getWriter();
		
		//接收jsp传过来的值
		String params = req.getParameter("param");
		//转码
		String param = new String(params.getBytes("ISO-8859-1"), "UTF-8"); 
		
		String dcmpparam = req.getParameter("dcmpparam");
		
		String dcmpmethod = req.getParameter("dcmpmethod");
		String index = "";
		if(param != null ||  !"".equals(param)){
			if("dcmptool".equals(dcmpparam)){
				index = dcmpToolUtil.doAction(param, dcmpmethod);
			}
		}
		out.println(index);
		
	}
}
